import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
//----------------------------------
//  gaCategory
//----------------------------------
/**
 *  @private
 *  Storage for the gaCategory property.
 */
private var _gaCategory:String;
/**
 *  String to be passed to Google as the Category property.
 *  <br/>
 *  An optional category for the event (e.g. "Videos").
 */
public function get gaCategory():String
{
	return _gaCategory;
}
/**
 *  @private
 */
[Inspectable(category="General", defaultValue="", type="String")]
public function set gaCategory(value:String):void
{
	_gaCategory = value;
}
//----------------------------------
//  gaAction
//----------------------------------	    
/**
 *  @public
 *  Storage for the gaAction property.
 */
private var _gaAction:String;
/**
 *  String to be passed to Google as the Action property.
 *  <br/>
 *  An optional action for the event (e.g. "Play").
 */
public function get gaAction():String
{
	return _gaAction;
}
/**
 *  @private
 */
[Inspectable(category="General", defaultValue="", type="String")]
public function set gaAction(value:String):void
{
	_gaAction = value;
}
//----------------------------------
//  gaLabel
//----------------------------------
/**
 *  @private
 *  Storage for the gaLabel property.
 */
private var _gaLabel:String;
/**
 *  String to be passed to Google as the Label property.
 *  <br/>
 *  An optional descriptor for the event.
 */
 public function get gaLabel():String
{
	return _gaLabel;
}
/**
 *  @private
 */
[Inspectable(category="General", defaultValue="", type="String")]
public function set gaLabel(value:String):void
{
	_gaLabel = value;
} 
//----------------------------------
//  gaValue
//----------------------------------
/**
 *  @private
 *  Storage for the gaValue property.
 */
private var _gaValue:Number;
/**
 *  Number to be passed to Google as the Value property.
 *  <br/>
 *  An optional value to be aggregated with the event. 
 */
public function get gaValue():Number
{
	return _gaValue;
}
/**
 *  @private
 */
[Inspectable(category="General", defaultValue="0", type="Number")]
public function set gaValue(value:Number):void
{
	_gaValue = value;
}	
//----------------------------------
//  gaMode
//----------------------------------
/**
 *  @private
 *  Storage for the gaMode property.
 */
private var _gaMode:String = "unique";
/**
 *  String to set tracking mode for compoment. ( unique | all | none )
 *  <br/>
 *  This property defaults to unique. Set to all to track all events or none to disable tracking
 */
public function get gaMode():String
{
	return _gaMode;
}
/**
 *  @private
 */
[Inspectable(category="General", enumeration="unique,all,none", defaultValue="unique", type="String")]
public function set gaMode(value:String):void
{
	_gaMode = value;
}
/**
 *  @private
 *  ArrayCollection holds references of items that have already been tracked
 */
private var trackedItems:ArrayCollection = new ArrayCollection();
 /**
 *  @private
 *  Calls trackEvent method on RxTracker instance
 */
private function trackIt(gaCategory:String,gaAction:String,gaLabel:String,gaValue:Number):void{
	/* 
	 * if in unique tracking mode, 
	 * check to see if it has already been tracked
	 */
	if(gaMode == "unique" && trackedItems.getItemIndex(gaCategory+""+gaAction+""+gaLabel+""+gaValue) < 0){
		if(Tracker.getInstance().trackEvent(gaCategory,gaAction,gaLabel,gaValue)){
			trackedItems.addItem(gaCategory+""+gaAction+""+gaLabel+""+gaValue);
		}
	/* 
	 * if in all tracking mode, 
	 */
	} else if(gaMode == "all"){
		Tracker.getInstance().trackEvent(gaCategory,gaAction,gaLabel,gaValue);
	} 
}